// const xss = require('xss');
const { exec, escape } = require('../db/mysql');
const { genPassword } = require('../utils/cryp'); // 加密

const login = (username, password) => {
    name = escape(username);
    password = genPassword(password);
    password = escape(password);
    const sql = `SELECT username, password, realname, type FROM user WHERE username='${username}' and password=${password}`;
    return exec(sql).then(rows => {
        return rows[0] || {};
    });
}

module.exports = {
    login
};